<%@ Page Title="Lang_LanguageType List" Language="C#" AutoEventWireup="true" CodeBehind="Lang_LanguageTypeList.aspx.cs" Inherits="Youz.CreditRepay.Manage.Lang_LanguageTypeList" %>

<script>
    //loadCSS("assets/plugins/gritter/css/jquery.gritter.css");

    var requireJS = [
        //"assets/plugins/gritter/js/jquery.gritter.min.js"
    ];

    loadJS(requireJS);
</script>
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading" data-original-title>
                <h2><i class="fa fa-align-justify"></i><span class="break"></span><%: R(LanguageModule.Lang_LanguageType, "Lang_LanguageType", "Lang_LanguageType") %></h2>
                <div class="panel-actions"></div>
            </div>
            <div class="panel-body">
                <div class="alert alert-danger" style="display: none;">
                    <button type="button" class="close" data-dismiss="alert">×</button><strong><i class="fa fa-warning"></i></strong><span class="content"></span></div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <div class="input-group">
                            <input type="email" id="input2-group2" name="input2-group2" class="form-control" placeholder="Search..."><span class="input-group-btn">
                                <button type="button" class="btn btn-primary">
                                <i class="fa fa-search "></i>
                                <%: R(LanguageModule.M_Common, "Query") %></button></span>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12">
                    <div class="form-group">
                        <a href="#" class="btn btn-info" onclick="loadPage('Lang/Lang_LanguageTypeItem.aspx')"><i class="fa fa-plus"></i>
                            <%: R(LanguageModule.M_Common, "Add") %></a>
                        <a href="#" class="btn btn-info" id="btnEdit"><i class="fa fa-edit "></i>
                            <%: R(LanguageModule.M_Common, "Edit") %></a>
                        <a href="#" class="btn btn-info" id="btnDelete"><i class="fa fa-trash-o "></i>
                            <%: R(LanguageModule.M_Common, "Delete") %></a>
                    </div>
                </div>
                <table id="table" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%"></table>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var dt;

    $(function () {

        dt = $('#table').DataTable({
            "paging": false,
            "ajax": {
                "url": 'Lang/Handlers/Lang_LanguageTypeHandler.ashx?type=list',
                "type": "POST",
                "dataSrc": "",
                "data": function (d) {
                }
            },
            "columns": [

                    { "data": 'LanguageCode', "title": "<%: R(LanguageModule.Lang_LanguageType, "LanguageCode", "国际通用语言编码") %>", visible: false },
                    { "data": 'LanguageName', "title": "<%: R(LanguageModule.Lang_LanguageType, "LanguageName", "语言名") %>" },
                    { "data": 'Icon', "title": "<%: R(LanguageModule.Lang_LanguageType, "Icon", "小图标") %>" },
                    { "data": 'DateFormat', "title": "<%: R(LanguageModule.Lang_LanguageType, "DateFormat", "时间格式") %>" },
                    { "data": 'IsEnable', "title": "<%: R(LanguageModule.Lang_LanguageType, "IsEnable", "是否启用") %>", render: fYesNo },
                    { "data": 'IsDefault', "title": "<%: R(LanguageModule.Lang_LanguageType, "IsDefault", "是否默认") %>", render: fYesNo },
                    { "data": 'CreateTime', "title": "<%: R(LanguageModule.Lang_LanguageType, "CreateTime", "新建时间") %>" },
                    { "data": 'Creator', "title": "<%: R(LanguageModule.Lang_LanguageType, "Creator", "新建人") %>" },
                    { "data": 'ModifiedTime', "title": "<%: R(LanguageModule.Lang_LanguageType, "ModifiedTime", "修改时间") %>" },
                    { "data": 'Modifier', "title": "<%: R(LanguageModule.Lang_LanguageType, "Modifier", "修改人") %>" },
            ]
        });

          //delete selected row
          $('#btnDelete').click(function () {
              if ($('#table tbody tr.selected').length > 0) {
                  jconfirm("<%: R(LanguageModule.M_Common, "DeleteConfirm") %>", function () {
                    //console.log(dt.row('.selected').data());
                    $.post("Lang/Handlers/Lang_LanguageTypeHandler.ashx?type=delete<%: WebHelper.Get("st") %>", { LanguageCode: dt.row('.selected').data().LanguageCode }, function (data) {
                        if (data) {
                            if (data.isSuccess) {
                                dt.ajax.reload();

                                $.gritter.add({
                                    title: '<%: R(LanguageModule.M_Common, "TipSuccess") %>',
                                    text: data.message,
                                    class_name: 'gritter-success'
                                });

                                $('#table tbody tr.selected').remove();
                            }
                            else {
                                $(".alert > .content").html(data.message);
                                $(".alert").show();
                            }
                        }
                    }, "json");
                });
            }
            else {
                $(".alert > .content").html("<%: R(LanguageModule.M_Common, "SelectRecord") %>");
                $(".alert").show();
            }
        });

          //delete selected row
          $('#btnEdit').click(function () {
              if ($('#table tbody tr.selected').length > 0) {
                  loadPage("Lang/Lang_LanguageTypeItem.aspx?LanguageCode=" + dt.row('.selected').data().LanguageCode);
              }
              else {
                  $(".alert > .content").html("<%: R(LanguageModule.M_Common, "SelectRecord") %>");
                $(".alert").show();
            }
        });

      });
</script>
